package com.wanmait.spacesys.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wanmait.spacesys.vo.Managerinfo;

/**
 * 进入到管理员首页进不去 需要登录 
 */
@WebFilter("/web/manager/*")
public class ManagerFilter implements Filter {

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		HttpServletResponse res = (HttpServletResponse) response;
		
		Managerinfo managerinfo = (Managerinfo)req.getSession().getAttribute("Managerinfo");
		if(managerinfo==null) {
			res.sendRedirect(req.getContextPath()+"/web/managerLogin.jsp");
		}
		else {
			chain.doFilter(req, res);
		}
	}



}
